home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / docs / misc / ConcNews.lha / news / amiga.programming / comp.sys.amiga.programmer_5437_000026.msg < prev    next >
Encoding:
Text File  |  1994-11-27  |  2.1 KB  |  63 lines

  1. Path: dd.chalmers.se!news.chalmers.se!sunic!EU.net!howland.reston.ans.net!cs.utexas.edu!rutgers!concert!sas!mozart.unx.sas.com!jamie
  2. From: jamie@cdevil.unx.sas.com (James Cooper)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Find device name and unit number
  5. Message-ID: <CKpKFK.A6u@unx.sas.com>
  6. Date: 4 Feb 94 16:28:29 GMT
  7. References: <2isjec$8ok@midland.co.nz>
  8. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  9. Organization: SAS Institute Inc.
  10. Lines: 49
  11. Originator: jamie@cdevil.unx.sas.com
  12. Nntp-Posting-Host: cdevil.unx.sas.com
  13.  
  14.  
  15. In article <2isjec$8ok@midland.co.nz>, pid@midland.co.nz (Philip D'Ath) writes:
  16. >I am maintaining an application, and need to be able to find out the device
  17. >name and unit number from a reference such as "DH0".
  18. >
  19. >So, for example, lets say that someone has a GVP hard drive, that is
  20. >called DH0:.  If DH0: is selected, then I want to be able to find out
  21. >that it is using the device "gvpscsi.device", and unit x.
  22. >
  23. >I've had a look through a reasonable amount of documentation, but haven't
  24. >managed to find a method to do this yet.
  25.  
  26. #include <dos/dosextens.h>
  27. #include <dos/filehandler.h>
  28.  
  29. ...
  30.         struct DosList *dlist, *tdlist;
  31.         struct FileSysStartupMsg *fssm;
  32.         ULONG unit;
  33.         char dvrname[34], *nptr;
  34.         int i;
  35.  
  36.         dlist = LockDosList(LDF_DEVICES|LDF_READ);
  37.  
  38.         tdlist = dlist;
  39.         tdlist = FindDosEntry(tdlist, "DH0", LDF_DEVICES);
  40.  
  41.         fssm = (struct FileSysStartupMsg *)BADDR(tdlist->dol_Startup);
  42.  
  43.         strcpy(dvrname, (char *)BADDR(fssm->fssm_Device));
  44.         unit = fssm->fssm_Unit;
  45.  
  46.         UnLockDosList(LDF_DEVICES|LDF_READ);
  47. ...
  48.  
  49. At this point, 'unit' contains the unit number, and 'drvname' has the
  50. device driver name... you'll need to add appropriate error checking, of
  51. course, and this will only work under 2.0+ of the OS...
  52.  
  53.  
  54. -- 
  55. ---------------
  56. Jim Cooper
  57. (jamie@unx.sas.com)                             bix: jcooper
  58.  
  59. Any opinions expressed herein are mine (Mine, all mine!  Ha, ha, ha!),
  60. and not necessarily those of my employer.
  61.  
  62. Remember, "Euphemisms are for the differently brained."
  63.